<div id="lib_Tab1">
<div class="lib_Menubox lib_tabborder">
<ul>
	<li id="one1" onclick="setTab('one',1,6)" class="hover">数据库配置</li>
	<li id="one2" onclick="setTab('one',2,6)" >固定表查询设置</li>
	<li id="one3" onclick="setTab('one',3,6)">表设置</li>  
	<li id="one4" onclick="setTab('one',4,6)">用户管理</li>
	<li id="one5" onclick="setTab('one',5,6)">mmc配置管理</li>
	<li id="one6" onclick="setTab('one',6,6)">备份表配置</li>
</ul>
</div>
<div class="lib_Contentbox lib_tabborder">  
	<div id="con_one_1" >
  	<!--数据库配置信息-->
	</div>
	<div id="con_one_2" style="display:none">
  	<!--固定表配置-->
	</div>
	<div id="con_one_3" style="display:none">
  	<!--比较条数与固定同步的表设置-->
	</div>
	<div id="con_one_4" style="display:none">
  	<!--用户管理-->
	</div> 
	<div id="con_one_5" style="display:none">
  	<!--mmc配置管理-->	
	</div> 
	<div id="con_one_6" style="display:none">
	<!--备份表配置-->
	
	</div> <span id="alltables"></span>
</div>

</body>
<script type="text/javascript" >

showConfigInfo( 'one', '1' );

//显示配置信息
function showConfigInfo( id, n ){
	$.ajax({
		type:'POST',
		async:false,
		url:'ajax/config.ajax.php' ,
		data:"act=" + n,
		success:function(msg){
			$('#con_'+id+'_'+n).html(msg);
		}
	})
//	if ( n == '6' ){		
//		$('#showallconfigtable').toggle(lookforalltable, hidealltable);
//	}
}
//配置
function configHandling(type, head){
	if (type == 'update'){
		$.ajax({
			type:'POST',
			async:false,
			url:'ajax/comparedb.ajax.php',
			data:"act=editconfig&type="+type+"&table="+$('#content1').val()+'&asyn='+$('#content2').val()+'&domain='+$('#content3').val()+'&maindb='+$('#content4').val()+'&field='+$('#content5').val()+'&index='+$('#content6').val()+'&autosql='+$('#content7').val(),
			success:function(msg){
				alert(msg);
				editConfig();
				setTab('one', 3, 6);
			}
		})
	}else{
		var str = "";
		$("input[name^='"+head+"']").each(function(){
			if (trim($(this).val()) == '' && (type == 'adddb' || type == 'addtype' || type == 'adduser' || type == 'addback') ){
				alert('不能为空');
				return;
			}
			str+=$(this).val()+"@@@";
		})
		$("textarea[name^='"+head+"']").each(function(){
			if (trim($(this).val()) == '' && (type == 'adddb' || type == 'addtype' || type == 'adduser' || type == 'addback') ){
				alert('不能为空');
				return;
			}
			str+=$(this).val()+"@@@";
		})
		$.ajax({
			type:'POST',
			async:false,
			url:'ajax/comparedb.ajax.php',
			//data:"act=editconfig&data="+str+'&type='+type,
			data:{
				'act' : 'editconfig',
				'data' : str,
				'type' : type
			},
			success:function(msg){
				alert(msg);
				editConfig();
				if (type == 'addtype' || type == 'edittype' || type =='deltype'){
					setTab('one', 2, 6);
				}else if (type == 'adduser' || type == 'edituser' || type =='deluser'){
					setTab('one', 4, 6);
				}else if (type == 'addback' || type == 'editback' || type =='delback'){
					setTab('one', 6, 6);
				}
			}
		})
	}
}

//配置mmc
function configMmc(type, head){
	var str = "";
	$("input[name^='"+head+"']").each(function(){
		if (trim($(this).val()) == '' && type == 'addmmc' ){
			alert('不能为空');
			return;
		}
		str+=$(this).val()+"@@@";
	})
	$.ajax({
		type:'POST',
		async:false,
		url:'ajax/comparedb.ajax.php',
		data:"act=editmmc&data="+str+'&type='+type,
		success:function(msg){
			alert(msg);
			editConfig();
			setTab('one', 5, 6);
		}
	})

}

//批量添加
function configBatch(type){
	if ($('#'+type).val() == ''){
		alert('请输入数据');
		return;
	}
	$.ajax({
		type:'POST',
		async:false,
		url:'ajax/comparedb.ajax.php',
		data:"act=batch&type="+type+"&data="+$('#'+type).val(),
		success:function(msg){
			alert(msg);
			editConfig();
			if (type == 'batch_mmc'){
				setTab('one', 5, 6);
			}
		}
	})

}
function trim(str){ //删除左右两端的空格    
	return str.replace(/(^\s*)|(\s*$)/g, "");    
} 

function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=i==cursel?"hover":"";
		con.style.display=i==cursel?"block":"none";
	}
	showConfigInfo(name, cursel);
}


//显示主库的所有表
function lookforalltable(){	
	$.ajax({
		type:'POST',
		async:false,
		url:'ajax/comparedb.ajax.php',
		data:"act=allconfigtable",
		success:function(msg){
			$('#alltables').html(msg);
		}
	})
}
function hidealltable(){
	$('#alltables').html('');
}
</script>